use bindgen;
use std::env;
use std::path::PathBuf;

fn main() {

    //链接目录和链接库
    println!("cargo:rustc-link-search=/opt/homebrew/lib");
    println!("cargo:rustc-link-lib=dylib=pcre2-8");

    #[cfg(feature = "enable-auto-bindings")]
    {
        let bindings = bindgen::Builder::default()
            .clang_args(&["-I/opt/homebrew/include"])
            .header("wrapper.h")
            //.whitelist_function("xxx") //默认全部函数,或者指定的函数
            .generate()
            .expect("unable to generate hello bindings");

        let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
        bindings.write_to_file(out_path.join("bindings.rs"))
            .expect("couldn't write bindings!");
    }
}
